package com.woniuxy.yoga.progress.web.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.yoga.commons.core.model.Result;
import com.woniuxy.yoga.commons.web.log.YogaLog;
import com.woniuxy.yoga.progress.model.form.TeamRegisterForm;
import com.woniuxy.yoga.progress.model.param.TeamRegisterParam;
import com.woniuxy.yoga.progress.service.TeamRegistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 团课上课记录表 前端控制器
 * </p>
 *
 * @author 韦用文,刘存益,郎腾霄
 * @since 2023年11月28日
 */
@RestController
@RequestMapping("/teamRegist")
@Api(tags = "团课上课记录管理")
@Validated
public class TeamRegistController {

    @Autowired
    private TeamRegistService teamRegistService;

    /**
     * 上课记录
     * @param form 参数
     * @return String
     */
    @PostMapping("/teamRegister")
    @ApiOperation("上课记录表")
    @YogaLog("上课记录表")
    public Result<String> teamRegister(@RequestBody @Valid TeamRegisterForm form){
        teamRegistService.teamRegister(BeanUtil.toBean(form, TeamRegisterParam.class));
        return Result.getResult(String.class).setMessage("记录成功");
    }
}

